﻿using System;
using System.IO;
using Ionic.Utils.Zip;
using Rosetta.Default;

namespace Rosetta.AddIns.Compression
{
    public sealed class ZipEntryOutputter : Outputter
    {
        #region Constructors

        public ZipEntryOutputter()
            : base("ZipEntry Outputter")
        {
            Category = "Compression";

            Add<ZipEntry, DirectoryInfo>("Extract", Extract, "entry", "baseDirectory");
        }

        #endregion

        #region Class Methods

        private static void Extract([NotNull] ZipEntry entry, [NotNull] DirectoryInfo baseDirectory)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }
            if (baseDirectory == null)
            {
                throw new ArgumentNullException("baseDirectory");
            }

            entry.Extract(baseDirectory.FullName);
        }

        #endregion
    }
}